package com.ptp.backendcertms.business.controller;

import com.ptp.backendcertms.api.external.dto.req.CodeReqDto;
import com.ptp.backendcertms.api.external.dto.res.CodeResDto;
import com.ptp.backendcertms.api.external.dto.res.ResponseDto;
import com.ptp.backendcertms.basiccompnents.http.ResponseWrapper;
import com.ptp.backendcertms.business.service.ICodeBusinessService;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 公共业务控制器
 *
 * @author songcongcong
 * @date 2025/5/6
 */
@RestController
@RequestMapping("/cms")
public class CodeBusinessController {
    @Resource
    private ICodeBusinessService codeBusinessService;

    /**
     * 查询码值列表
     */
    @RequestMapping(value = "/code/query", method = RequestMethod.POST)
    public ResponseDto<CodeResDto> getCodes(@RequestBody @Valid CodeReqDto reqDto, BindingResult bindingResult) {
        return ResponseWrapper.responseReturnWithValid(bindingResult, "[码值管理]-码值列表查询",
                () -> codeBusinessService.getCodes(reqDto));
    }
}
